import request from '@/config/axios'

/** 书籍信息 */
export interface Book {
          id: number; // 书籍表ID
          bookName?: string; // 书籍名称
          bookShelfId: number; // 绘本集ID
          cover?: string; // 封面图片
  }

// 书籍 API
export const BookApi = {
  // 查询书籍分页
  getBookPage: async (params: any) => {
    return await request.get({ url: `/book/book/page`, params })
  },

  // 查询书籍详情
  getBook: async (id: number) => {
    return await request.get({ url: `/book/book/get?id=` + id })
  },

  // 新增书籍
  createBook: async (data: Book) => {
    return await request.post({ url: `/book/book/create`, data })
  },

  // 修改书籍
  updateBook: async (data: Book) => {
    return await request.put({ url: `/book/book/update`, data })
  },

  // 删除书籍
  deleteBook: async (id: number) => {
    return await request.delete({ url: `/book/book/delete?id=` + id })
  },

  /** 批量删除书籍 */
  deleteBookList: async (ids: number[]) => {
    return await request.delete({ url: `/book/book/delete-list?ids=${ids.join(',')}` })
  },

  // 导出书籍 Excel
  exportBook: async (params) => {
    return await request.download({ url: `/book/book/export-excel`, params })
  }
}
